package learn.java;
import java.util.*;
public class MaxNumString
{
	public static void main(String[] args)
	 {
		String data = "aaaabbbbccccc";
Map<Character,Integer> countMap = new HashMap<Character,Integer>();
		for(int i=0;i<data.length();i++)
		{
			char c = data.charAt(i);
			if(countMap.containsKey(c))
			{
				countMap.put(c,countMap.get(c)+1);
			}
			else
			{
				countMap.put(c, 1);
			}
		}
		
		for(Map.Entry<Character, Integer> me:countMap.entrySet())
		{
			System.out.println(me.getKey()+"\t" + me.getValue());
		}
		LinkedList<Character> list=new LinkedList<Character>();
		int max=0;
		for(Map.Entry<Character, Integer> me:countMap.entrySet())
		{
			if(me.getValue()<max)
			{
				continue;
			}
			if(me.getValue()==max)
			{
				list.add(me.getKey());
			}
			if(me.getValue()>max)
			{
				list.clear();
				max=me.getValue();
				list.add(me.getKey());
			}
		}
		System.out.println("the most repeated character is:");
		Character c=list.getFirst();
		System.out.println(c+"\t" + max);
		}
	}

